package com.hnue.k60b.adapter;

import java.util.List;

import com.hnue.k60b.models.RssItem;
import com.hnue.k60b.newapplication.R;


import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class NewAdapter extends ArrayAdapter<RssItem> {

	private Context context;
	private List<RssItem> items;
	private int ivIcon;

	public NewAdapter(Context context, int ivIcon, List<RssItem> items) {
		super(context, ivIcon, items);
		this.context = context;
		this.items = items;
		this.ivIcon = ivIcon;

	}

	// moi hang sẽ có 2 cột, icon và tên báo
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// khi tao ra view mới, cho phép add thêm 1 hàng mới
		// systemservice sẽ trả về 1 object
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		// khởi tạo 1 dòng
		View rowview = inflater.inflate(R.layout.news, parent, false);
		TextView tv1 = (TextView) rowview.findViewById(R.id.title);
		TextView tv2 = (TextView) rowview.findViewById(R.id.description);
		TextView tv3 = (TextView) rowview.findViewById(R.id.pubdate1);
		
		tv1.setTextColor(Color.BLUE);
		tv1.setText(items.get(position).getTitle());
		tv3.setText(items.get(position).getDate());
		tv2.setText(items.get(position).getDescription());
		return rowview;
	}

}
